#欢迎界面
#主操作界面
#功能项：查询余额、取钱、存钱、转账、修改密码、退出主操作界面


#主界面
def welcome():
	print("="*65)
	print()
	print(" "*27,"CSDN银行"," "*30 )
	print()
	print(" "*17,"尊敬的客户您好，欢迎使用ATM机！"," "*30 )
	print()
	print("{0:1}{1:13}".format(" ","1.插入银行卡"))
	print("="*65)
	print()
#welcome()
#登录界面
def register():
	print("="*65)
	print()
	print(" "*27,"CSDN银行"," "*30 )
	print()
	print(" "*22,"请您输入账号与密码"," "*30 )
	print()
	print("{0:1}{1:13}{2:10}{3:13}".format(" ","1.请输入账号与密码"," "*35,"2.退出系统" ))
	print("="*65)
	print()
#register()
#密码验证输入
def pagepass():
	print()
	print("="*65)
	print()
	print(" "*27,"CSDN银行"," "*30 )
	print()
	print(" "*22,"请您输入账号与密码"," "*30 )
	print()
	print("="*65)
	print()
#pagepass()
#密码错误界面
def pagepasserror():
	print("="*65)
	print()
	print(" "*27,"CSDN银行"," "*30 )
	print()
	print(" "*21,"您输入的账号与密码错误"," "*30 )
	print()
	print("{0:1}{1:13}{2:10}{3:13}".format(" ","1.重新输入"," "*38,"2.退出系统" ))
	print("="*65)
	print()
#pagepasserror()
#主操作界面
def pagemain():
	print("="*65)
	print()
	print(" "*14,"尊敬的客户您好，欢迎使用CSDN银行业务"," "*20 )
	print()
	print("{0:1}{1:13}{2:10}{3:13}".format(" "*10,"1.查询余额"," "*20,"4.转账" ))
	print()
	print("{0:1}{1:13}{2:10}{3:13}".format(" "*10,"2.取款"," "*20,"5.修改改密码" ))
	print()
	print("{0:1}{1:13}{2:10}{3:13}".format(" "*10,"3.存款"," "*20,"6.退出系统" ))
	print()
	print("="*65)
	print()
#pagemain()

#用户数据
user_list = [
    {'countnum':'zhangsan','cash':'10000','password':'123456'},
    {'countnum':'lisi','cash':'20000','password':'321312'},
    {'countnum':'wangwu','cash':'30000','password':'654654'},
    {'countnum':'zhaoliu','cash':'40000','password':'987987'}
]

#定义函数
#global userid
def syswel():
    welcome()
    key1 = input('请输入对应的选择：')
    if key1 == '1':
        syspass()

#密码验证
def syspass():
    register()
    key2=input('请输入对应的选择：')
    if key2 == '1':
        pagepass()
        key3 = input('请输入您的银行账户：')
        key4 = input('请输入您的账户密码：')
        check_list=(key3,key4)
        for i in user_list:
            userpass= (i['countnum'],i['password'])
            if check_list == userpass:
                global userid
                userid=i
                sysmain()
            else:
                pagepasserror()
    if key2 == '2':
        syswel()
    else:
        syswel()

#修改密码

def che_pass():
    oldpass=input('请输入您的原密码')
    if oldpass ==user_list[userid]['password']:
        print(' '*20,'请修改密码')
        newpass_1=input('请输入您的新密码：')
        newpass = input('请再次输入您的新密码：')
        if newpass_1==newpass:
            user_list[userid]['password']=newpass
        else:
            print(' '*20,'您两次输入的密码不一致')
            che_pass()
    else:
        che_pass()

#主要操作函数

def sysmain():
    pagemain()
    sel_1=input('请输入对应的选择：')
    if sel_1=='1':
        usercash = user_list[userid]['cash']
        print('您的账户余额为：',usercash,'元')
        print('按1返回主界面：')
        sel_1_1=input('请输入对应的选择')
        if sel_1_1 == '1':
            sysmain()
    elif sel_1=='2':
        get_cash=input('请输入您的取款金额：')
        user_list[userid]['cash']-=int(get_cash)
        get_cash_2=input('确认请按1：')
        sysmain()
    elif sel_1=='3':
        set_cash = input('请输入您的存款金额：')
        user_list[userid]['cash'] += int(set_cash)
        set_cash_2 = input('确认请按1：')
        sysmain()
    elif sel_1=='4':
        print('请输入转账账户与金额')
        tra_name=input('请输入您要转账的账户：')
        tra_cash = input('请输入您要转账的金额：')
        user_list[userid]['cash']-=int(tra_cash)
        for j in range(len(user_list)):
            tra_name2={user_list[j]['cash']}
            if tra_name==tra_name2:
                user_list[j]['cash']+=int(tra_cash)
                break
        tra_cash_2=input('确认请按1:')
        sysmain()
    elif sel_1=='5':
        print('请修改密码')
        che_pass()
        che_pass1=input('确认请按1：')
        sysmain()
    elif sel_1=='6':
        print(' '*20,'谢谢使用，再见')
        exit1=input('返回上一次请按1   退出系统请按2：')
        if exit1=='1':
            sysmain()
        if exit1=='2':
            syswel()
    else:
        print('无效的输入，请重新输入')
        null1 = input('返回上一次请按1   退出系统请按2：')
        null1 = input('返回上一次请按1   退出系统请按2：')
        if null1 == '1':
            sysmain()
        if null1 == '2':
            syswel()
syswel()




